from django.db import models
# Create your models here.


class Artist(models.Model):
    name = models.CharField(max_length=30,verbose_name="名称")
    alias = models.CharField(max_length=30,verbose_name="别名")
    brief_desc = models.CharField(max_length=255,verbose_name="描述")
    trans = models.CharField(max_length=255,verbose_name="翻译")
    pic_url = models.ImageField(verbose_name="路径",upload_to='photos')
    created_at = models.DateTimeField(auto_now_add=True,verbose_name="创建时间")
    updated_at = models.DateTimeField(auto_now=True,verbose_name="修改时间")

    def __str__(self):
        return self.name+'-'+self.alias

    class Meta:
        verbose_name="作者"
        verbose_name_plural = "作者"


class Album(models.Model):
    name = models.CharField(max_length=30,verbose_name="名称")
    type = models.CharField(max_length=30,verbose_name="类型")
    description = models.CharField(max_length=50,verbose_name="描述")
    pic_url = models.ImageField(verbose_name="路径",upload_to='photos')
    company = models.CharField(max_length=100,verbose_name="公司")
    publish_at = models.DateTimeField(verbose_name="发布时间")
    created_at = models.DateTimeField(auto_now_add=True,verbose_name="创建时间")
    updated_at = models.DateTimeField(auto_now=True,verbose_name="修改时间")
    artist = models.ForeignKey('Artist',verbose_name="作者")

    def __str__(self):
        return self.name

    class Meta:
        verbose_name="专辑"
        verbose_name_plural = "专辑"


class Song(models.Model):
    name = models.CharField(max_length=30,verbose_name="名称")
    alias = models.CharField(max_length=30,verbose_name="别名")
    position = models.IntegerField(verbose_name="偏移量")
    duration = models.IntegerField(verbose_name="总量")
    mp3_url = models.FileField(verbose_name="路径",upload_to='mp3')
    album = models.ForeignKey('Album',verbose_name="专辑")
    created_at = models.DateTimeField(auto_now_add=True,verbose_name="创建时间")
    updated_at = models.DateTimeField(auto_now=True,verbose_name="修改时间")

    def __str__(self):
        return self.name+'-'+self.alias

    class Meta:
        verbose_name="歌曲"
        verbose_name_plural = "歌曲"




